#include"HashTable.h"

namespace MySet{
    template<class K>
    class UnorderedSet{
        struct SetKeyOfT{
            const K& operator()(const K& key){
                return key;
            }
        };
    public:
        typedef typename Hash_bucket::HashTable<K,K,SetKeyOfT>::const_iterator iterator;
        typedef typename Hash_bucket::HashTable<K,K,SetKeyOfT>::const_iterator const_iterator;

        const_iterator begin()const {
            return _hashtable.begin();
        } 

        const_iterator end()const {
            return _hashtable.end();
        }

        //这里的pair<iterator,bool>中的iterator是const_iterator类型,而插入函数返回的是iterator类型
        //所以这里需要进行一下类型转换，从iterator类型到const_iterator类型
        pair<iterator,bool> insert(const K& key){
            pair<iterator,bool> rit=_hashtable.Insert(key);
            return pair<const_iterator,bool>(rit.first,rit.second);
        }

    private:
        Hash_bucket::HashTable<K,K,SetKeyOfT> _hashtable;
    };
};